﻿using System;
using System.Collections.Generic;
using System.Text;
using CodeMeter;

namespace VisionCloud.Utility
{
    public class WibuDog : EncryptionDog
    {
        private Api cm;
        public override bool IsExistHardwareDog()
        {
            bool returnBl = true;
            HCMSysEntry hcmse = null;				// handle of CmContainer or CmContainer entry
            string serials = "";
            cm = new Api();
            // Create a "subsystem Access" to the local subsystem
            CmAccess2 cmaccess = new CmAccess2();
            cmaccess.Ctrl = CmAccess.Option.SubSystem;
            hcmse = cm.CmAccess2(CmAccessOption.Local, cmaccess);
            if (null == hcmse)
            {
                return false;
            }
            else
            {
                //if (logging) log.detailed("    Subsystem Access successful. Handle: {0}.", hcmse.handle);
                returnBl = true;

            }
            // get infos of connected CmContainers
            // first determine the number of CmContainers
           var currentBoxInfo = cm.CmGetBoxes(hcmse, CmGetBoxesOption.AllPorts);
            if (currentBoxInfo.Length == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public override string ReadEncryptionDog()
        {
            throw new NotImplementedException();
        }



        public override bool StartEncryptionDog()
        {
            throw new NotImplementedException();
        }

        public override bool WriteEncryptionDog(byte[] bts)
        {
            throw new NotImplementedException();
        }
    }
}
